@extends('layouts._order')
@section('main')
    <div class="i_bg bg_color">
        <!--Begin 用户中心 Begin -->
        <div class="m_content">

            @include('layouts._orderleft')

            <div class="m_right" id="addres">
                <p></p>
                <div class="mem_tit">收货地址</div>
                <div class="address"  v-for="v in datas">

                    <div class="a_close">
                        <a @click="del(v.address_id)"><img src="/images/extimg/a_close.png" /></a>
                    </div>
                    <table border="0" class="add_t" align="center" style="width:98%; margin:10px auto;" cellspacing="0" cellpadding="0">
                        <tr>
                            <td align="right" width="100">收货人姓名：</td>
                            <td>@{{v.address_name}}</td>
                        </tr>
                        <tr>
                            <td align="right">配送区域：</td>
                            <td>@{{v.province['0'].region_name}}@{{v.city['0'].region_name}}@{{v.district['0'].region_name}}</td>
                        </tr>
                        <tr>
                            <td align="right">详细地址：</td>
                            <td>@{{v.address}}</td>
                        </tr>
                        <tr>
                            <td align="right">手机：</td>
                            <td>@{{v.mobile}}</td>
                        </tr>
                        <tr>
                            <td align="right">电话：</td>
                            <td>@{{v.tel}}</td>
                        </tr>
                        <tr>
                            <td align="right">电子邮箱：</td>
                            <td>@{{v.email}}</td>
                        </tr>
                        <tr>
                            <td align="right">标志建筑：</td>
                            <td>@{{v.sign_building}}</td>
                        </tr>
                    </table>

                    <p align="right">

                        <a :href="'/ordercenter/save_delivery_address?address_id='+v.address_id" style="color:#ff4e00;">编辑</a>&nbsp; &nbsp; &nbsp; &nbsp;
                    </p>

                </div>
            </div>
        </div>
        <!--End Footer End -->
    </div>
@endsection
@section('js')
    {{--编写js代码--}}
    <script src="{{ mix('js/app.js') }}"></script>
    <script>
        new Vue({
            el:'#addres',
            data:{
                datas:[],
            },
            //事件触发的函数在这里面
            methods:{
                del:function (address_id) {
                    var token = "{{session('admin')}}";
                    layer.confirm("确认要删除吗，删除后不能恢复",function(index){
                        layer.close(index);
                        $.ajax({
                            type:'get',
                            url:"http://shopapi.cn/api/my/delMyAddress",
                            data:{
                                token:token,
                                address_id:address_id
                            },
                            success:function(res)
                            {
                                layer.msg(res.msg);
                                history.go(0);
                            }
                        });
                    });
                }
            },

            mounted(){
                var token = "{{session('admin')}}";
                var user_id = "{{ session('admin_info.user_id') }}";

                axios({
                    method: 'get',
                    url: 'http://shopapi.cn/api/my/myAddress',
                    params: {
                        token: token,
                        user_id: user_id
                    }
                })
                .then(
                    (res)=>{
                        this.datas=res.data.data;
                    }
                );
            },
        });
    </script>
    @endsection